export function mergePromise<T>(ajaxArray: Promise<any>[]) {
  let p: any = Promise.resolve();
  const arr: any[] = [];
  ajaxArray.forEach((promise: any) => {
    p = p.then(promise).then((data: any) => {
      arr.push(data);
      return arr;
    });
  });
  return p as Promise<T>;
}

export function awaitWrapType<T>(promise: any): [any, T | null] {
  return promise
    .then((data: T) => [undefined, data])
    .catch((err: any) => [err, undefined]);
}
